﻿using Inovout.Cloud.Applications.Models;
using Inovout.Models;
using Inovout.Runtime;
using Inovout.Security;
using System.Collections.Generic;

namespace Inovout.Cloud.Applications.Security.Models
{
    partial class ApplicationUser : User
    {
         
        public ApplicationUser()
        {
            Credentials = new DataObjectSet<IApplicationCredential>();
        }
        private string name;
        private static readonly string nameFormat;
        static ApplicationUser()
        {
            nameFormat = ComponentRegistry.Resolve<IApplication>().Settings["ApplicationUserIdentityFormat"].ToString();
        }
        public override string Name
        {
            get
            {
                return name;
            }
            set
            {
                    if (string.IsNullOrEmpty(this.name))
                    {
                        this.name = string.Format(nameFormat, value);
                    }
                    else
                    {
                        this.name = value;
                    }
            }
        }
        public virtual Application Application
        {
            get;
            set;
        }
        public virtual ISet<IApplicationCredential> Credentials { get; set; }
        public virtual ISystemUser SystemUser
        {
            get;
            set;
        }
    }

}
